package bis;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

public class FLManagerMgr extends FLBaseMgr {

    public void setdelete(String bm) {
        super.bm = bm;
        this.BaseDelete();
    }

    public void setUpdate(FLManager aflm) {
        QueryStr = "select * from tblManager where Bm='" + aflm.bm + "'";
        UpdateStr = "update tblManager set mc='" + aflm.mc + "',Mm='" + aflm.mm + "',qx='" + aflm.qx + "' where Bm='" + aflm.bm + "'";
        super.BaseUpdate();
    }

    @Override
    public void BaseDelete() {
        QueryStr = "select bm from tblManager where Bm='" + bm + "'";
        UpdateStr = "delete from tblManager where Bm='" + bm + "'";
        super.BaseDelete();
    }

    public boolean isInsert(String mc, String mm, String qx) {
        InsertStr = "insert into tblManager(Bm,mc,Mm,qx) values('" +super.getmaxbybm("tblManager")+ "','" + mc + "','" + mm + "','" + qx + "')";
        return Insert();
    }

    private ArrayList GetDate() {
        ArrayList list = new ArrayList();
        ResultSet rs = super.Query();
        try {
            while (rs.next()) {
                FLManager flm = new FLManager(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4));
                list.add(flm);
            }
        } catch (SQLException ex) {
            Logger.getLogger(FLManagerMgr.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (list.isEmpty()) {
            return null;
        } else {
            return list;
        }
    }

    public ArrayList getDateById() {
        QueryStr = "select * from tblManager where mc='" + super.bm + "'";
        return GetDate();
    }

    public ArrayList getAllDate() {
        QueryStr = "select * from tblManager";
        return GetDate();
    }
}
